## The function period(f,q)

from PyM import *


def period(f,q):
    x = variable(f)
    r = degree(f)
    D = divisors(q**r-1)
    for d in D:
        if (x**d-1) % f == 0:
            return d
    

p = 5

[_,x] = polynomial_ring(Zn(p),'x')


f = x**p -x + 1
f = f>>Zn(5)

show(period(f,p))




